<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        const account = '123';
        const password = '123';
        let chance = 3;  // 登录的总次数
        let money = 1000; // 账户余额

        let isLoop = true;

        while (chance > 0) {
            const input_account = prompt('请输入账号：');
            const input_password = prompt('请输入密码：');

            if (input_account == account && input_password == password) {
                console.log("登录成功！");

                while (isLoop) {
                    const option = prompt("请选择业务: 1.查询 2.存款 3.取款 4.退出");
                    switch (option) {
                        case "1":
                            console.log(`账户余额为: ${money}`);
                            break;
                        case "2":
                            while (true) {
                                const saveMoney = prompt('请输入存款金额：') - 0;
                                // money = money + saveMoney;
                                money += saveMoney;
                                console.log(`存款金额为:${saveMoney}, 账户余额为:${money}`);
                                const isContinue = prompt('是否继续存款：(y/n)');
                                if (isContinue === 'n') {
                                    break; // 结束最近的while
                                }
                            }
                            break; // 结束switch
                        case "3":
                        case "4":
                            console.log("谢谢使用再见！");
                            // 结束内部小循环
                            isLoop = false;
                            // 结束外部大循环
                            chance = 0;
                            // 结束switch
                            break;
                    }
                }

            } else {
                chance--;
                if (chance > 0) {
                    console.log(`账号或密码错误，你还有${chance}次机会`);
                } else {
                    console.log('登录次数已用完，再见！');
                }
            }
        }



    </script>
</body>

</html>